<!-- 作者详情 -->
<script setup lang="ts">
import { getAuthor } from '@/api/getAxios'
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { useRouter } from 'vue-router';

const $router = useRouter()
const $route = useRoute()
const data = ref()

getAuthor(<any>$route.query.uid).then((res) => {
    data.value = res.data.data
})
const onClickLeft = function () {
    $router.go(-1)
}
</script>
<template>
    <div class="content">
        <van-nav-bar left-text="返回" left-arrow @click-left="onClickLeft" />
        <div class="bg"></div>
        <div class="move">
            <div class="main box" v-if="data">
                <div><img v-if="data.faceUrl" :src="data.faceUrl" alt=""><img v-else src="../assets/img/icons8-头像-96.png"
                        alt=""></div>
                <div>
                    <p>{{ data.authorName }}</p>
                    <p>{{ data.signature }}</p>
                </div>
            </div>
            <div class="message box" v-if="data">
                <ul>
                    <li>
                        <p v-if="data.focusCount">{{ data.focusCount }}<span>人</span></p>
                        <p v-else>0<span>人</span></p>
                        <p>订阅量</p>
                    </li>
                    <li>
                        <p v-if="data.fansCount">{{ data.fansCount }}<span>人</span></p>
                        <p v-else>0<span>人</span></p>
                        <p>追随者</p>
                    </li>
                    <li>
                        <p v-if="data.storyList">{{ data.storyList.length }}<span>部</span></p>
                        <p v-else>0<span>部</span></p>
                        <p>作品</p>
                    </li>
                </ul>
            </div>
            <div class="all box">
                <h1>全部作品</h1>
                <li v-for="item in data.storyList" v-if="data"
                    @click="$router.push({ path: '/BookInfo', query: { storyId: item.id } })">
                    <p>
                        <img :src="item.cover" alt="">
                    </p>
                    <div>
                        <p>{{ item.name }}</p>
                        <p>{{ item.introduce }}</p>
                        <p>{{ item.type }}</p>
                    </div>
                </li>
            </div>
        </div>
    </div>
</template>

<style scoped lang='less'>
.content {
    font-family: var(--mfont);
    padding: 10px;
    padding-top: 46px;
}

.bg {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    height: 180px;
}

.move {
    position: relative;
    z-index: 99;
}

.main {
    display: flex;

    div:nth-child(1) {
        margin-right: 10px;
    }

    img {
        width: 66px;
        height: 66px;
        overflow: hidden;
        border-radius: 50%;
    }

    div:nth-child(2) {
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex: 1;

        p:nth-child(1) {
            font-size: 1.2rem;
        }

        p:nth-child(2) {
            color: #888;
            font-size: .9rem;
            margin-top: 6px;
        }
    }

    button {
        border: 0;
        border-radius: 24px;
        height: 34px;
        font-size: .8rem;
        background-color: #15CD9C;
        padding: 0 18px;
        color: whitesmoke;
        transition: all 0.2s;

        &:active {
            opacity: 0.8;
        }
    }
}

.message {
    ul {
        display: flex;
        justify-content: space-around;

        li {
            text-align: center;

            p:first-child {
                font-size: 1.1rem;
                margin-bottom: 6px;
            }

            span {
                font-size: .9rem;
                margin-left: 4px;
            }

            p:nth-child(2) {
                font-size: .9rem;
            }
        }
    }
}

.all {
    h1 {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }

    li {
        display: flex;
        margin: 10px 0;
        padding: 10px 0;
        border-radius: 8px;

        &:active {
            background-color: whitesmoke;
        }

        >p {
            width: 32%;

            img {
                width: 100%;
                border-radius: 8px;
            }
        }

        div {
            margin-left: 10px;
            width: 100%;
            display: flex;
            flex-direction: column;
            justify-content: space-between;

            p:nth-child(1) {
                font-size: 1rem;
                margin-bottom: 6px;
            }

            p:nth-child(2) {
                word-break: break-all;
                overflow: hidden;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                font-size: .9rem;
                color: #888;
            }

            p:nth-child(3) {
                font-size: .9rem;
                color: #4e4e4e;
            }
        }
    }
}

.box {
    border-radius: 10px;
    background-color: white;
    margin: 10px 0;
    padding: 18px;
}

.van-nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: transparent;
    z-index: 999;
}</style>